import request from '@/config/axios'

// 资源申请 VO
export interface SourceApplyVO {
  id: number // 主键
  applyCode: string // 申请编号
  applyUserId: number // 申请人
  phone: string // 联系方式
  useEndTime: Date // 使用期限
  applyReson: string // 使用理由
  file: string // 附件
  sourceApplyDetails?: any[] // 申请明细
  sourceList?: any[] // 申请明细
  operateFlag?: string // save 暂存, submit 提交
}

// 资源申请 API
export const SourceApplyApi = {
  // 查询资源申请分页
  getSourceApplyPage: async (params: any) => {
    return await request.get({ url: `/bpm/source-apply/page`, params })
  },

  // 查询资源申请详情
  getSourceApply: async (id: number) => {
    return await request.get({ url: `/bpm/source-apply/get?id=` + id })
  },

  // 新增资源申请
  createSourceApply: async (data: SourceApplyVO) => {
    return await request.post({ url: `/dr/source-apply/create`, data })
  },

  // 新增资源申请带流程
  createSourceApplyBpm: async (data: SourceApplyVO) => {
    return await request.post({ url: `/bpm/source-apply/create`, data })
  },

  // 修改资源申请
  updateSourceApply: async (data: SourceApplyVO) => {
    return await request.put({ url: `/bpm/source-apply/update`, data })
  },

  // 删除资源申请
  deleteSourceApply: async (id: number) => {
    return await request.delete({ url: `/bpm/source-apply/delete?id=` + id })
  },

  // 导出资源申请 Excel
  exportSourceApply: async (params) => {
    return await request.download({ url: `/bpm/source-apply/export-excel`, params })
  },
}
